package dto.api;

import models.application.AniApi;

import java.util.List;

/**
 * User: yeh
 * Date: 5/30/13
 * Time: 3:24 PM
 * For:  wilddragon
 */
public class ApiInfoDto {
    public Long id;

    public String state;

    public String type;

    public String apiName;

    public String url;

    public String method;

    public String description;

    public List<ApiParamDto> params;

    public ApiInfoDto(Long id, String state, String type, String apiName, String url, String method, String description, List<ApiParamDto> params) {
        this.id = id;
        this.state = state;
        this.type = type;
        this.apiName = apiName;
        this.url = url;
        this.method = method;
        this.description = description;
        this.params = params;
    }

    public static ApiInfoDto generateFromDao(AniApi oneApi){
        return new ApiInfoDto(
                oneApi.id,
                oneApi.state.stateKey,
                oneApi.type.typeKey,
                oneApi.apiName,
                oneApi.url,
                oneApi.method.httpMethodKey,
                oneApi.description,
                ApiParamDto.generateFromDaoList(oneApi.params)
        );
    }
}
